package com.team2.shoppingService;

import java.util.ArrayList;
import java.util.List;

import com.team2.imageComparison.CyberImageMatcher;
import com.team2.shared.ServerProduct;

public class ImageCompareThread extends Thread {
	private List<ServerProduct> processedList;
	private String targetPath;
	ImageCompareThread(String targetPath, List<ServerProduct> products){
		super("ImageComparisionThread");
		this.targetPath = targetPath;
		this.processedList = products;
	}
	
	public void run(){
		for(ServerProduct product: processedList){
			product.setImageFilePath(Util.loadImage(product.getImageLink()));
			try{
				product.setSimilarity(CyberImageMatcher.getMatchedArea(targetPath, product.getImageFilePath()));
			}
			catch(Exception e){
				e.printStackTrace();
			}
			}
	}

	public List<ServerProduct> getProcessedList() {

		return processedList;
	}

}
